四则运算:
ef arithmetic(a, b, operator):
    if operator == "+":
        return a + b
    elif operator == "-":
        return a - b
    elif operator == "*":
        return a * b
    elif operator == "/":
        return a / b

n = 1
if n > 0:
    operator = input("选择运算：+，-，*，/:\n")
    a = int(input("请输入一个数a:\n"))
    b = int(input("请输入一个数b:\n"))
    print("a" + operator + "b = ", arithmetic(a, b, operator))

取模:
a = int(input("请输入一个数a:\n"))
b = int(input("请输入一个数b:\n"))
if b == 0:
  print("b不能为0")
else:
  c = a % b
print(c)

求幂:
a = float(input("请输入底数a：\n"))
b = float(input("请输入指数b：\n"))
print("a ** b = ",a ** b)

阶乘:
from functools import reduce
n = 7
print(reduce(lambda x,y:x*y,range(1,n+1)))

三角函数:
# Python code to demonstrate example
# of all Trigonometric functions

# importing math module
import math

# number
x = 0.75

# math.cos()
print("math.cos(", x, "): ", math.cos(x));
# math.sin()
print("math.sin(", x, "): ", math.sin(x));
# math.tan()
print("math.tan(", x, "): ", math.tan(x));

# math.acos()
print("math.acos(", x, "): ", math.acos(x));
# math.asin()
print("math.asin(", x, "): ", math.asin(x));
# math.atan()
print("math.atan(", x, "): ", math.atan(x));

y = 2
# math.atan2(y,x) = atan(y/x)
print("math.atan2(", y, ",", x, "): ", math.atan2(y, x))

# math.hypot(x,y)
print("math.hypot(", x, ",", y, "): ", math.hypot(x, y))

解一元二次方程:
import math
def quadratic(a, b, c):
    if not isinstance(a, (int, float)):
        raise TypeError('a is not a number')
    if not isinstance(b, (int, float)):
        raise TypeErrot('b is not a number')
    if not isinstance(c, (int, float)):
        raise TypeError('c is not a number')
    derta = b * b - 4 * a * c
    if a == 0:
        if b == 0:
            if c == 0:
                return '方程根是全体实数'
            else:
               return '方程无根'
        else:
            x1 = -c / b
            x2 = x1
            return x1, x2
    else:
        if derta < 0:
            return '方程无根'
        else:
            x1 = (-b + math.sqrt(derta)) / (2 * a)
            x2 = (-b - math.sqrt(derta)) / (2 * a)
            return x1, x2
print(quadratic(2, 3, 1))
print(quadratic(1, 3, -4))

